<!DOCTYPE html>
<html lang="zh-CN">
<head>
	<meta charset="utf-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<meta name="renderer" content="webkit" />
	<link href="../css/bootstrap.min.css" rel="stylesheet" />
	<link href="../css/font-awesome.min.css" rel="stylesheet" />
	<link href="../css/animate.css" rel="stylesheet" />
	<link href="../css/style.css" rel="stylesheet" />
	<link href="../css/plugins/toastr/toastr.min.css" rel="stylesheet">
</head>
<body class="top-navigation">
	<div id="wrapper">
		<div id="page-wrapper" class="gray-bg dashbard-1">
			<div class="row border-bottom">
<nav class="navbar navbar-static-top" data-role="navigation">
<!-- 以下是顶部导航栏，需要根据页面配置 -->
					<div class="navbar-header">
						<div class="minimalize-styl-2">
						
<!-- 请确保下面的<a>标签中的href属性地址和相对路径一致 -->
							<a class="btn btn-success" title="返回主页" href="main.html"><i class="fa fa-lg fa-home"></i></a>
<!-- 请确保上面的<a>标签中的href属性地址和相对路径一致 -->

							<a class="back-link btn btn-success" title="后退"><i class="fa fa-lg fa-arrow-left"></i></a>
							<a class="reload-link btn btn-success" title="重新加载"><i class="fa fa-lg fa-repeat"></i></a>

<!-- 以下是指示页面上下文的部分，需要根据实际路径修改 -->
							<ol id="guide" class="breadcrumb m-l">
<!-- <li><a>上级页面的上级页面</a><li> -->
<!-- <li><a>上级页面</a><li> -->
<!-- <li><strong>当前页面</strong><li> -->
								<li><strong>主页</strong></li>
							</ol>
<!-- 以上是指示页面上下文的部分，需要根据实际路径修改 -->

						</div>
					</div>
					<div class="nav navbar-top-links navbar-right minimalize-styl-2">
						<span class="m-r-sm text-muted welcome-message btn btn-link">欢迎使用Feces物流管理系统</span>
					</div>
<!-- 以上是顶部导航栏，需要根据页面配置 -->
				</nav>
			</div>
			
			
			
			
			<!-- 配置点2 -->
			<!-- 内容 -->
			<div class="wrapper wrapper-content animated fadeInRight">
			
			
			
			
				<!-- 配置点2.1 -->
				<!-- 段落1 -->
				<div class="row">
					<div class="col-lg-12">
						<div class="ibox float-e-margins">
							<div class="ibox-title">
								<h5>查询订单信息</h5>
							</div>
							<div class="ibox-content">
     
				<table class="table table-striped table-bordered table-hover ">
				<tr><td>订单号：</td>
				<td>
					<input type="text" class="sub-info" id="sub_id" placeholder="请输入订单号" required="">
				</td></tr>
				<tr><td>录入时间：</td>
				<td>
					<input type="text" class="sub-info" id="sub_date" placeholder="请输入录入时间" required="">
				</td></tr>
				<tr><td>客户姓名：</td>
				<td>
					<input type="text" class="sub-info" id="sub_name"  placeholder="请输入客户姓名" required="">
				</td></tr>
				<tr><td>订单类型：</td>
				<td>
					<input type="text" class="sub-info" id="sub_type" placeholder="请输入订单类型" required="">
				</td></tr>
				</table>
				<button type="button" onclick="fnClickAddRow();" class="btn btn-success block full-width m-b">查询</button>
								<!-- 配置点2.2 -->
				<!-- 段落2 -->
				<div class="row">
					<div class="col-lg-12">
						<div class="ibox float-e-margins">
							<div class="ibox-title">
								<h5>查询结果</h5>
							</div>
							<div class="ibox-content">
							<table class="table table-striped table-bordered table-hover "
								id="editable">
								
								
							<thead>
								<tr>
										<th>订单号</th>
										<th>客户编号</th>
										<th>客户姓名</th>
										<th>电话</th>
										<th>商品名称</th>
										<th>商品数量</th>
										<th>订单类型</th>
										<th>订单状态</th>
										<th>退定</th>
										<th>退货</th>
								</tr>
							</thead>

								<tfoot>
									<tr>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
										<th></th>
									</tr>
								</tfoot>
							</table>
		

							</div>
						</div>
					</div>
				</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
	
	
	<script src="../js/jquery-2.1.1.min.js"></script>
	<script src="../js/bootstrap.min.js"></script>
	<script src="../js/plugins/metisMenu/jquery.metisMenu.js"></script>
	<script src="../js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
	<script src="../js/feces.js"></script>
	<script src="../js/plugins/pace/pace.min.js"></script>
	<script src="../js/plugins/toastr/toastr.min.js"></script>
	<!-- Data Tables -->
	<script src="../js/plugins/dataTables/jquery.dataTables.js"></script>
	<script src="../js/plugins/dataTables/dataTables.bootstrap.js"></script>
	
	
	
	<!-- 配置点3 -->
	<!-- 载入后的js脚本 -->
	<script>
	var cl;
	$(function(){
		// you JavaScript code here!
	});
		var url = "../api/order";
		$(document).ready(function() {
			$('.dataTables-example').dataTable();

			/* Init DataTables */
			var oTable = $('#editable').dataTable();

			/* Apply the jEditable handlers to the table */
			oTable.$('td').editable('../example_ajax.php', {
				"callback" : function(sValue, y) {
					var aPos = oTable.fnGetPosition(this);
					oTable.fnUpdate(sValue, aPos[0], aPos[1]);
				},
				"submitdata" : function(value, settings) {
					return {
						"row_id" : this.parentNode.getAttribute('id'),
						"column" : oTable.fnGetPosition(this)[2]
					};
				},

				"width" : "90%",
				"height" : "100%"
			});

		});
		function chanpro(col)
		{
			if((cl.status!="缺货")||(cl.status!="可分配"))
			{
				alert("目前状态无法退货");
			}
			else
			{
				location.href="hwz_pro_exchange.jsp?id="+col;
			}
		}
		function chanorder(col)
		{
			if((cl.status!="缺货")||(cl.status!="可分配"))
			{
				alert("目前状态无法退订");
			}
			else
			{
				location.href="hwz_back_order.jsp?id="+col;
			}
			
		}

		function fnClickAddRow() {
		var name=$("#sub_name").val();
		var date=$("#sub_date").val();
		var ty=$("#sub_type").val();
		var id=$("#sub_id").val();
		
		$.ajax({
			type: "GET",
			url: url,
			data: {
				name     : name,
				id       : id,
				type     : ty,
				orderdate: date
			},
			success: function(result){
			var rs = result.data;
			var cll=rs;
			var lg=cll.length;
			for(var i=0;i<lg;i++)
			{
				cl=cll[i];
				var pd=cl.products;
				var plg=pd.length;
				if(plg==0)
				{
					$('#editable').dataTable()
					.fnAddData(
					[
					  cl.id,
					  cl.order_client.id,
					  cl.order_client.name,
					  cl.order_client.phone,
					  "null",
					  0,
					  cl.type,
					  cl.status]);
				}
				
				for(var j=0;j<plg;j++)
				{
					$('#editable').dataTable()
						.fnAddData(
						[
						  cl.id,
						  cl.order_client.id,
						  cl.order_client.name,
						  cl.order_client.phone,
						  pd[j].product.name,
						  pd[j].product_number,
						  cl.type,
						  cl.status,
						  "<a onclick='chanorder(id)'id='"
						  +cl.id
						  +"'>退订</a>"
						  ,
						  "<a onclick='chanpro(id)'id='"
						  +cl.id
						  +"'>退换货</a>"]);
				}
			}
		}
		});
		}			

	</script>
	
	
	
	
</html>
